home *** CD-ROM | disk | FTP | other *** search
- How to have a main .app and many .dll's sharing the common variables and files?
- ===============================================================================
- by Mander Li, May 1994.
-
-
- This question was first raised by Geoff Bomford in the Clarion EchoMail.
- I did some tests, and answered the question for one main .app and one .dll.
-
- When I put all the common variables and files in a .dll, say DLL0.APP,
- it compiles OK and successfully produces DLL0.DLL.
-
- Then I create another .app called DLL1.APP, which contains just a
- subroutine called DllForm. The DllForm accesses the common variables and
- files in DLL0. After the source codes are generated, I manually add the
- EXTERNAL attribute to the common variables and files in the file DLL1.CLA.
- The compilation is OK, but the linker says "$xxx is unresolved in yyy",
- where xxx is a common variable name, and yyy is a .CLA filename.
-
- Thanks to Jimmy Rogers, Nick Grasso and Gary Wegner for their replies in
- the Clarion EchoMail. They pointed out that I should link DLL0.DLL into
- DLL1.APP as well. This is done by inserting the DLL0.LIB as External
- Object Module in the Module Worksheet of DLL1.APP. Now the linker
- successfully produces the DLL1.DLL, with many "xxx is duplicated (dll)"
- warning messages. These warning messages can be ignored.
-
- Finally I have a MultiDll.APP which has a Form to display and allow the
- user to modify the common variable and file. The Form is called MainForm,
- it has a button to calls the DllForm in DLL1 to show that the DLL1 does
- share the same common variable and file buffer.
-
- All the .APP and related files are included in this ZIP file.
-
-
- Installation
- ============
- I suggest you create the directory C:\CLARION3\TEST\MULTIDLL and unzip all
- the files into this directory. Note that the .APP files are created in
- CDD 3.008.
-
-
- How to run the Demo
- ===================
- 1. Change directory to C:\CLARION3\TEST\MULTIDLL, and run CDD. First
- bring up the DLL0.APP, and press Alt-M is make the DLL0.DLL. Then
- bring up DLL1.APP, and press Alt-M is make the DLL1.DLL. And bring
- up MULTIDLL.APP, press Alt-A to make and run the program.
-
- 2. Press ENTER or click the Change button to bring up the Form. Enter
- something in the Common Var1 field. Then press Alt-G or click the
- 'Go to DLL' button is call the subroutine DllForm in DLL1.
-
- 3. Note that all the field are blank. This shows that the variable and
- file buffer are not passed to the DLL. This is because the variable
- and the file are declared as non-External in all the .APP files.
-
- 4. Now exit to DOS, and manually edit the files DLL1.CLA and MULTIDLL.CLA
- as follows:
-
- Locate and change the line: CommonVar1 STRING(10)
- to: CommonVar1 STRING(10),external
-
- Locate and change the line:
- testfile FILE,PRE(tes),DRIVER('Clarion'),CREATE,RECLAIM
- to:
- testfile FILE,PRE(tes),DRIVER('Clarion'),CREATE,RECLAIM,external('')
-
- 5. Run CDD, bring up DLL1.APP. Press Alt-L to re-compile and link
- without re-generating the source codes. Then bring up MULTIDLL.APP, and
- press Alt-L. When compilation and link edit is finished, press ENTER
- to exit. And then press Alt-R to run the program.
-
- 6. Repeat step 2 above. Note that this time the DllForm at the bottom
- displays the same value as the calling Form. This shows that both
- the main program and the DLL share the same variables and file buffer.
- If you change the value in the bottom form and press ENTER, the new
- value is reflected in the calling Form as well.
-
-
- Checklist
- =========
- If you don't get the same result as described above, ensure that:
- 1. The modules DLL101.CLA in DLL1.APP has the 'Called From This DLL
- Only' unchecked in the Module Attributes screen.
- 2. The changes in Step 4 above are still there in the file.
- 3. The DLL0.APP and DLL1.APP have the Project Settings as follows:
- 'Use Runtime Libraries' is unchecked
- 'Application Access Method is 'Procedure Call Library'
-